home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 451 < prev    next >
Encoding:
Text File  |  1996-08-06  |  7.8 KB  |  236 lines

  1. Path: news.ucdavis.edu!usenet
  2. From: "Harry H. Cheng" <hhcheng@ucdavis.edu>
  3. Newsgroups: comp.std.c
  4. Subject: CH Language Environment
  5. Date: Mon, 26 Feb 1996 16:54:20 -0800
  6. Organization: University of California, Davis
  7. Message-ID: <3132563C.3BA5@ucdavis.edu>
  8. NNTP-Posting-Host: dragon.engr.ucdavis.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.3 sun4m)
  13. Content-Disposition: inline; filename="l4"
  14.  
  15.  
  16.  
  17. I would like to announce that the CH language environment
  18. is available users of SunOS, Solaris, LynxOS.
  19. CH is designed as a superset of C interpreter.
  20. It can be used for Unix shell programming, WWW Common
  21. Gateway Interface, WWW Common Client Interface, ...
  22. The differences between CH and C are highlighted as follows:
  23.  
  24.  
  25. EXTENSIONS TO C (some features are currently debated by 
  26. C Standard Committee ANSI/X3J11 and ISO/SC22/WG14 as new 
  27. features
  28. of the next version of C standard called C9x)
  29.  
  30. (1) CH is an interpretive implementation of ANSI C as Unix shell.
  31.     It can be used as login shell. Here are some differences between 
  32.     CH and C shells.
  33.  
  34.           CH shell                           C shell
  35.     _path = "/usr/bin /bin"            set path = (/usr/bin /bin)
  36.     printf("%s\n", getenv("PATH"))
  37.     putenv("PATH=/usr/bin /bin")       setenv PATH "/usr/bin /bin" 
  38.     printf("%s\n", getenv("PATH"))     echo $PATH
  39.     echo $(getenv("PATH"))             echo $PATH
  40.     printf("%s\n", _path)              echo $path
  41.     remenv("PATH")                     unsetenv PATH
  42.     emvar("_path")                     unset path 
  43.     int i = 90                         set i =90
  44.     i = 91                             set i =91
  45.     string hostnam =`hostname`         set hostnam =`hostname`
  46.     alias("rm", "rm -i")               alias rm 'rm -r' 
  47.     unalias("rm")                      unalias rm 
  48.     _histsize = 100                    history = 100
  49.     history                            history 
  50.     ls ~ *                             ls ~ *
  51.     ls > output                        ls > output
  52.     ls $(getenv("PATH"))               ls $PATH
  53.     ls $_path                          ls $path
  54.     $l -agl                            !l -agl
  55.     $3                                 !3 
  56.     $-1                                !-1
  57.     $$                                 !!
  58.     more .chshrc .chlogin .chlogout    more .cshrc .login .logout
  59.     more .rchshrc .chlogin .chlogout   more .cshrc .login .logout
  60.     more .schshrc .chlogin .chlogout   more .cshrc .login .logout
  61.  
  62.     restricted shell                    restricted shell
  63.  
  64.  
  65. There is safe shell in CH for internet computing.
  66. In addition to restrictions imposed by conventional restricted shell,
  67. the following features are disallowed for across-network internet computing
  68. in safe CH shell.
  69.     (a) declaration of pointers.
  70.     (b) built-in functions remove(), rename(), unlink(), open(), and fopen().
  71. The restrictions above are enforced after .schshrc is interpreted.
  72. If CH is invoked with option -S, options -r and -f will be ignored.
  73.  
  74. (2) Complex is a built-in data type 
  75. handled similar to that in Fortran.
  76. For example,
  77.       float f=90;
  78.       complex z=complex(1,2);
  79.       z = 2*f*z*sin(z)*atan(z);
  80.  
  81. (3) String is a first-class object for across-network computing.
  82. For example,
  83.       string s, a[3];
  84.       s = "great string"
  85.       strcpy(a[0], s);
  86.       strcat(s, s);
  87.       printf("s = %s\n", s);
  88.  
  89. (4) Functions can be nested and recursively nested
  90. similar to implementation in GNU gcc.
  91. For example,
  92.       int func1() {
  93.          void func2() {
  94.             int func3() { ...}
  95.          }
  96.          ...
  97.          func2();
  98.       }  
  99.  
  100. (5) Arrays of variable length. They include
  101. deferred-shape arrays, assumed-shape arrays, and pointer
  102. to assumed-shape arrays.
  103. The following example will clarify the concepts of these
  104. various array definitions.
  105.   void funct(int a[:][:], (*b)[:], c[], n, m){
  106.   /* a: assumed-shape array */
  107.   /* b: pointer to array of assumed-shape */
  108.   /* c: incomplete array completed by function call */
  109.     int d[4][5];     /* d: fixed-length array */
  110.     int e[n][m];     /* e: deferred-shape array */
  111.     int (*f)[:];     /* f: pointer to array of assumed-shape */
  112.     extern int g[];  /* g: incomplete array completed by external linkage */
  113.     int h[] = {1,2}; /* h: incomplete array completed by initialization */
  114.     e[1][2] = a[2][3];
  115.   }
  116.   int A[3][4], B[5][6], C[3];
  117.   funct(A, B, C, 10, 20);
  118.   funct(B, A, C, 85, 85);
  119.  
  120. (6) Arrays of adjustable range.
  121. The range of subscript for an index of array can be adjusted.
  122. For example,
  123.   int a[1:10], b[-5:5], c[0:10][1:10], d[10][1:10], e[n:m], f[n1:m1][1:m2];
  124.   extern int a[1:], b[-5:], c[0:][1:10];
  125.   int funct(int a[1:], int b[1:10], int c[1:][3], int d[1:10][0:20]);
  126.   a[10] = a[1]+2; /* OK */
  127.   a[0] = 90;      /* Error: index out of range */
  128.  
  129. (7) Computational array.
  130. An array qualified by type qualifier {array} is
  131. called  computational array.
  132. A computational array is treated as  a first-class object
  133. as in Fortran 90. For example,
  134.        array float a[10][10], b[10][10];
  135.        a += b+inverse(a)*transpose(a)+sin(a);
  136.  
  137. (8) Fortran arrays.
  138. An array qualified by type qualifier {fortran} is
  139. called fortran-style array.
  140. Unlike a C array,
  141. elements of a fortran-style array are stored column-wise.
  142. For example,
  143.   fortran array float A[10][10], B[10][10];
  144.   fortran float a[10][10], b[10][10];
  145.   float *p;   
  146.   p = &a[0][0];
  147.   *(p+1) = 90; /* <==> a[1][0] = 90; not a[0][1] = 90 */
  148.   funct((float [10])&A[5][10]); /* pass column 6 to function funct() */
  149.  
  150. Fortran code can be ported to CH easily.
  151. We have ported over 10,000 lines of LAPACK package to CH.
  152.  
  153.  
  154. (9)Reference for internet computing.
  155. Reference for basic data types char, short, int,
  156. float, double, as well as data types qualified
  157. by signed, unsigned, long, complex, and dual
  158. can be declared.
  159. Functions can be called by reference.
  160. The same syntax in C++ is used in CH.
  161. For example,
  162.   int i;
  163.   int &j = i;
  164.   int A, B;
  165.   void swap(int &n, int &m); /* the same as in C++ */
  166.   swap(A, B);                /* pass by reference as in Fortran */
  167.  
  168. (10) Many high-level toolboxes and function files such as
  169.     plotxy(), plotxyz(), plotxyf(), plotxyzf() for plotting.
  170.  
  171.  
  172.  
  173. MISSING C FEATURES
  174. (1) struct/union/bit-fields.
  175. (2) pointer to functions.
  176. These features will be implemented in CH in the future.
  177.  
  178.  
  179. WHY CH?
  180.  
  181. (1) Like Java, CH can be used for across network
  182. world-wide distributed computing.
  183. It can be used for WWW Common Gateway Interface (CGI), 
  184. WWW Common Client Interface (CCI).
  185. Toolboxes for CGI and CCI are available.
  186. They are easy to use. Examples of World-Wide
  187. Distributed Computing in the CH language environment
  188. can be found on the WWW at the URL address
  189.    http://iel.ucdavis.edu/CH/tutor/wwdc/
  190.  
  191. (2) If you use common set of C and CH, 
  192. your CH code can be compiled in native C compiler.
  193. Your C programs without structure and pointer to functions
  194. can run in the CH language environment
  195. without compilation. 
  196. Normally, CH is 1.xx% to 100% slower than compiled C code, 
  197. depending on applications. But,
  198. if your code takes advantage of high-level features of CH,
  199. such as inverse(A) for computing inverse of matrix A,
  200. CH code can be 
  201. just as fast as your C program.
  202.  
  203.  
  204. (3) It can be used for rapid prototyping of real-time applications.
  205. It can be used to test your device drivers and hardware setup.
  206.  
  207. (4) Like Basic and C shell, CH is interactive.
  208. If you are not sure a C feature, you can verify it
  209. easily under the CH language environment. For example,
  210.  
  211.    prompt> hello.c
  212.    Hello, world!
  213.    (execute hello.c program without compilation)
  214.    prompt> int i, *p;
  215.    prompt> p = &i; 
  216.    prompt> *p = 90;
  217.    prompt> printf("i = %d\n", i);
  218.    i = 90
  219.    prompt> int **p2
  220.    prompt> p2 = &p
  221.    prompt> printf("**p2 = %d\n", **p2)
  222.    **p2 = 90
  223.    prompt> ls * > junkfile
  224.    (all file names go to junkfile)
  225.    prompt> 
  226.  
  227.  
  228. CH runs on SunOS, Solaris, MVME167/LynxOS 2.2.1.
  229. It is available free for downloading
  230. on the WWW at the URL address 
  231.    http://iel.ucdavis.edu/CH/
  232.  
  233.  
  234. Harry Cheng
  235.  
  236.